//
//  CustomPageViewController.m
//  iCinema
//
//  Created by Robin Daniels on 07/11/12.
//  Copyright (c) 2012 Robin Daniels. All rights reserved.
//

#import "CustomPageViewController.h"

@interface CustomPageViewController ()

@end

@implementation CustomPageViewController

- (void)viewDidLoad
{
	// Do any additional setup after loading the view, typically from a nib.
    [super viewDidLoad];
    
    // Toevoegen van childviews (swipen)
	[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"ViewAanbieding"]];
	[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"ViewFilm"]];
	[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"ViewAccount"]];
    self.navigationItem.hidesBackButton = YES;
    
    // Achtergrond
    UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"bg.jpg"]];
    self.view.backgroundColor = background;
}

- (void)showActionSheet:(id)sender {
    
    // Sheet aanmaken en weergeven als bevestiging voor het uitloggen
    sheet = [[UIActionSheet alloc] initWithTitle:@"Are you sure?"
                                        delegate:self
                               cancelButtonTitle:@"Cancel"
                          destructiveButtonTitle:nil
                               otherButtonTitles:@"Log out !", nil];
    [sheet showInView:self.view];
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    
    // index 0 = log out
    if(buttonIndex == 0) {

        // Opgeslagen account verwijderen
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        [defaults removeObjectForKey:@"gebruiker_id"];
        [defaults removeObjectForKey:@"email"];
        [defaults removeObjectForKey:@"voornaam"];
        [defaults removeObjectForKey:@"achternaam"];
        [defaults removeObjectForKey:@"geboortedatum"];
        [self.navigationController popToRootViewControllerAnimated:YES];
    }
}

@end
